#ifndef __PLATFORM_OBULLET_H__
#define __PLATFORM_OBULLET_H__
#include "physics/oBody.h"
#include "platform/oTypes.h"
#include "misc/oIDisposable.h"

class oWorld;

class oDLL b2QueryCallback;

namespace platform
{
	class oUnit;
	class oBulletDef;
	class oBullet;

	typedef delegate<bool (oBullet* bullet, oUnit* target)> oBulletHandler;

	class oDLL oBullet: public oBody
	{
	public:
		virtual ~oBullet();
		PROPERTY_READONLY(oUnit*, Owener);
		PROPERTY_BOOL(_isFaceRight, FaceRight);
		PROPERTY(CCNode*, _face, Face);
		PROPERTY_READONLY(oSensor*, DetectSensor);
		virtual void update(ccTime dt);
		virtual void onExit();
		void onBodyEnter(oSensor* sensor, oBody* body);
		void onFaceDisposed(oIDisposable* item);
		oBulletDef* getBulletDef();
		static oBullet* node(oWorld* world, oBulletDef* def, oUnit* unit);
		oTargetAllow targetAllow;
		oBulletHandler hitTarget;
		uint32 type;
		virtual void destroy();
	protected:
		oBullet(oWorld* world, oBulletDef* def, oUnit* unit);
		virtual void updateTransform();
	private:
		oBulletDef* _bulletDef;
		oSensor* _detectSensor;
		oUnit* _owner;
		float _lifeTime;
		float _current;
	};
}

#endif
